<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../ht-css/style-q.css" />
    <link rel="stylesheet" type="text/css" href="../../ht-css/Project.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>客户信息检索</title>
</head>
<body>
<article class="page-container">
    <form class="ml-20 mr-20" id="form-member"  method="post">
        <div class="bg-1 bk-gray pb-10" style="width: 650px;">
            <table class="table table-border table-bg table-hover table-sort mt-8" id="datatable">
                <thead>
                <tr class="text-c">
                    <th width="2px">券类型</th>
                    <th width="2px">电子券主题编号</th>
                    <th width="2px">电子券主题名称</th>
                    <th width="2px">面额</th>
                    <th width="2px">有效期</th>
                    <th width="2px">操作</th>
                </tr>
                </thead>
                <tbody class="shun">
                </tbody>
            </table>
            <!--<div class="mt-40"></div>-->
            <!--<div class="dataTables_wrapper goods_fanye clearfix mt-5">
                <div class="f-r pageturning M-box3"></div>
            </div>-->
        </div>

    </form>
</article>
<div style="text-align: center">
    <a onclick="cancelBtn()" id="cancelBtn" class="btn btn-secondary radius size-S ml-20">取消</a>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script src="../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<!--引入分页-->
<link rel="stylesheet" href="../../ht-css/contract/paginationnn.css">
<script src="../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script src="../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../ht-js/Customer/Customer.js?rev=@@hash"></script>
<script>
    console.log(getQueryString('sendCouponId'))
    function cancelBtn() {
        parent.layer.closeAll();
    }
    var sendCouponIdsss= getQueryString('sendCouponId')
    ss();
    function ss() {
        $.ajax({
            url:root.couponInter.getCopyExtension,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            data: {
                sendCouponId:sendCouponIdsss,

            },
            success: function (data) {

                couponlidst(data.data);
                if(data.errorCode==1){
                    $.Huimodalalert(data.msg,2000);
                }
                console.log(data)

            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        })
    }
 function couponlidst(data){
        console.log(data)
        dataSource.splice(0,dataSource.length);//清空数组
     if(data!=null&&data!=""){
        $.each(data, function (i, field) {
            var rowData = new Array();
            rowData.push(field.topicType);
            rowData.push(field.topicCode);
            rowData.push(field.topicName);
            rowData.push(field.amount);
            rowData.push(field.dayNumber);
            rowData.push(field.useBegtime);
            rowData.push(field.useEndtime);
            rowData.push(field.copyUrl);
            rowData.push(field.topicStatus);
            rowData.push(field.topicId);
            dataSource.push(rowData);
        });
     }
        initDataTable(dataSource);

        function initDataTable(dataSource) {
            var dttable = $('#datatable').dataTable(); // 初始化dataTable，清空上一个值
            dttable.fnClearTable(); //清空一下table
            dttable.fnDestroy(); //还原初始化了的datatable
            $("#datatable").DataTable({
                "order": [[ 5, "desc" ]],
                "autoWidth": false,
                "ordering": false,
                "searching": false,
                "paging": false,
                "retrieve": false,
                "destroy": false,
                "bAutoWidth": false,
                "bLengthChange": false,
                "aLengthMenu": [20,40,60],
                "oLanguage": {
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "抱歉， 没有找到",
                    "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                    "sInfoEmpty": "没有数据",
                    "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"
                    },
                    "sZeroRecords": "没有检索到数据",
                },
                data: dataSource,
                columnDefs: [
                    {
                        "visible": true,
                        "targets": 0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = '';
                            if (row[0] == 10) {
                                val = '满减'
                            }
                            else if (row[0] == 20) {
                                val = '运费'
                            }
                            return val;
                        },
                        "targets": 0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = '';
                            if(row[4]>0){
                                val='领到券当日开始'+row[4]+'天内有效'
                            }else{
                                val = row[5]+'<br>~<br>'+row[6]
                            }
                            return val;
                        },
                        "targets":4
                    },

                    {
                        "render": function (data, type, row, meta) {

                                var val = '<input id="'+row[9]+'" value='+row[7]+' readonly/><input id="topicStatus" value="'+row[8]+'" style="display:none"> <input type="button" class="btn btn-secondary size-S radius ml-10" onclick="copyUrl('+row[9]+')" value="复制链接">'
                                return val
                        },
                        "targets": 5
                    },
                ]
            });
        };
    }


    function copyUrl(e) {
        if($('#topicStatus').val()==10){
            var Url=document.getElementById(e);
            console.log($(Url).val());
            Url.select(); // 选择对象
            document.execCommand("Copy"); // 执行浏览器复制命令
            $.Huimodalalert('复制成功！',2000);
        }else{
            $.Huimodalalert('提示：该电子券已失效！',2000);
        }
    }
</script>
</body>
</html>